﻿namespace Leetcode.N0668;
public class Solution
{
    public int FindKthNumber(int m, int n, int k)
    {
        var left = 1;
        var right = m * n;
        while (left < right)
        {
            var val = left + (right - left) / 2;
            var count = val / n * n;
            for (int i = val / n + 1; i <= m; i++)
            {
                count += val / i;
            }

            if (count >= k)
            {
                right = val;
            }
            else
            {
                left = val + 1;
            }
        }
        return left;
    }
}
